
*replication_main_results.do
*This version: 17th August 2021
*First version: 9th August 2021

*Replication files for
*Huse, C. And N. Koptyug (2021), “Salience and Policy Instruments: Evidence from the Auto Market”, to appear at JAERE (Journal of the Association of *Environmental and Resource Economists).
*The replication package consists of two files:
*replication_data.dta --> data file in Stata format
*replication_main_results.do --> code replicating the main results of the paper

clear all
cd "C:\Users\huse-admin\Dropbox\Option Valuation of FFV\Replication Material"

use replication_data

describe

***********************************************************************************************************************
*Table 3 - Demand and Valuation Estimates
***********************************************************************************************************************


*T3 - Col 1
xi: clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p tc, group(x1) robust
estimates store t3_col1
disp _b[tc]/_b[p]
testnl _b[tc]/_b[p]=1

*T3 - Col 2
xi: clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p npv_c, group(x1) robust
estimates store t3_col2
disp _b[npv_c]/_b[p]
testnl _b[npv_c]/_b[p]=1

*T3 - Col 3
xi: clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p npv_c npv_t, group(x1) robust
estimates store t3_col3
disp _b[npv_c]/_b[p]
testnl _b[npv_c]/_b[p]=1
disp _b[npv_t]/_b[p]
testnl _b[npv_t]/_b[p]=1

*T3 - Col 4
xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1) rand(p tc) ln(2) robust
estimates store t3_col4
mixlbeta tc p if e(sample), saving("indiv_coefs_t3_col4.dta") replace

*T3 - Col 5
xi: clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1) rand(p npv_c) ln(2) robust
estimates store t3_col5
mixlbeta p npv_c if e(sample), saving("indiv_coefs_t3_col5.dta") replace

*T3 - Col 6
xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1) rand(p npv_c npv_t) ln(3) robust robust difficult technique(bfgs 50 dfp 50)
estimates store t3_col6
mixlbeta p npv_c npv_t if e(sample), saving("indiv_coefs_t3_col6.dta") replace



***********************************************************************************************************************
*Table 4 - Salience of Vehicle Tax
***********************************************************************************************************************
gen npv_salient = .
gen npv_nonsalient = .

***********************************************************************************************************************
** Tax Payments Due
***********************************************************************************************************************
gen tax_month = .
replace tax_month = 3 if x20 == "0"
replace tax_month = 4 if x20 == "1"
replace tax_month = 5 if x20 == "2"
replace tax_month = 6 if x20 == "3"
replace tax_month = 8 if x20 == "4"
replace tax_month = 10 if x20 == "5"
replace tax_month = 11 if x20 == "6"
replace tax_month = 12 if x20 == "7"
replace tax_month = 1 if x20 == "8"
replace tax_month = 2 if x20 == "9"

gen ym1 = x4+1
gen ym2 = x4+2
gen ym3 = x4+3

gen tax_due = (tax_month==month(dofm(ym1)))
gen tax_quarter = (tax_month==month(dofm(ym1))|tax_month==month(dofm(ym2))| tax_month==month(dofm(ym3)))

********************************************************************************
*T4 - Col 1 ** Older than 5 years
********************************************************************************
	replace npv_salient = npv_t*(x13>=5)
	replace npv_nonsalient = npv_t - npv_salient 
	xi:  clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p npv_c npv_nonsalient npv_salient, group(x1) robust

 	matrix c = e(b)'
	svmat c
	replace c1 = -12 in 118		
	replace c1 = -12.50 in 119
	replace c1 = -19 in 120
	replace c1 = -15 in 121
	replace c1 = 0.01 in 122	
	replace c1 = 0.01 in 123
	replace c1 = 2 in 124
	replace c1 = 1 in 125
	mkmat c1 in 1/125			
	drop c1

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1) rand(p npv_c npv_nonsalient npv_salient) ln(4) robust from(c1, copy) difficult technique(bfgs 50 dfp 50) nrep(100) burn(30)

	estimates store t4_col1_inc
	mixlbeta p npv_c npv_nonsalient npv_salient if e(sample), saving("indiv_coefs_t5_col1_inc.dta") replace


********************************************************************************
*T4 - Col 2 ** Older than 5 years & Due next quarter
********************************************************************************
	replace npv_salient = npv_t*(x13>=5)*tax_quarter
	replace npv_nonsalient = npv_t - npv_salient 

	xi:  clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p npv_c npv_nonsalient npv_salient, group(x1) robust
	
 	matrix c = e(b)'
	svmat c
	replace c1 = -11.95348 in 118		
	replace c1 = -12.46766 in 119
	replace c1 = -21.57562 in 120
	replace c1 = -12.09687 in 121
	replace c1 = .0053386 in 122		
	replace c1 = -.0123367 in 123
	replace c1 = -2.08112 in 124
	replace c1 = -.4179979 in 125
	mkmat c1 in 1/125
	drop c1

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_c npv_nonsalient npv_salient) ln(4) robust from(c1, copy) difficult technique(bfgs 50 dfp 50) nrep(100) burn(30)
	estimates store t4_col2
	mixlbeta p npv_c npv_nonsalient npv_salient if e(sample), saving("indiv_coefs_t5_col2_inc.dta") replace

********************************************************************************
*T4 - Col 3 ** Older than 5 years & Due next month
********************************************************************************
	replace npv_salient = npv_t*(x13>=5)*tax_due
	replace npv_nonsalient = npv_t - npv_salient 

	xi:  clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p npv_c npv_nonsalient npv_salient, group(x1) robust

 	matrix c = e(b)'
	svmat c
	replace c1 = -12 in 118		
	replace c1 = -12.50 in 119
	replace c1 = -16 in 120
	replace c1 = -12 in 121
	replace c1 = 0.01 in 122	
	replace c1 = 0.01 in 123
	replace c1 = 0.1 in 124
	replace c1 = 0.1 in 125
	mkmat c1 in 1/125			
	drop c1

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1) rand(p npv_c npv_nonsalient npv_salient) ln(4) robust from(c1, copy) difficult technique(bfgs 50 dfp 50) 
	estimates store t4_col3_inc
	mixlbeta p npv_c npv_nonsalient npv_salient if e(sample), saving("indiv_coefs_t5_col3_inc.dta") replace








	

***********************************************************************************************************************
*Table 5 - Salience of fuel costs
***********************************************************************************************************************

***********************************************************************************************************************
* T5 - Col 1 *Oil above $100
***********************************************************************************************************************
gen oil_high = (ym(2011,11)<=mofd(date) & ym(2012,5)>=mofd(date))
gen oil_npv =  oil_high * npv_c

replace npv_nonsalient = npv_c - oil_npv
replace npv_salient = oil_npv

xi: clogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29 p npv_nonsalient npv_salient npv_t, group(x1)  robust

xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50) nrep(100) burn(30)
	estimates store t5_col1_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t6_col1_inc.dta") replace

***********************************************************************************************************************
*T5 - Col 2 * Fuel Around Round Numbers
***********************************************************************************************************************
gen gas_round2 = -( 13.90<=x21 & x21<=14.10 |14.90<=x21 & x21<=15.10 | 15.90<=x21 & x21<=16.10) * (x3 == "g") * npv_c
gen diesel_round2 = -( 13.90<=x22 & x22<=14.10 |14.90<=x22 & x22<=15.10 | 15.90<=x22 & x22<=16.10)* (x3 == "d") * npv_c

replace npv_nonsalient  = npv_c + gas_round2 + diesel_round2
replace npv_salient = -gas_round2-diesel_round2

xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t5_col2_inc_10c
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t6_col2_inc.dta") replace

***********************************************************************************************************************
*T5 - Col 3 * Highest Upswing/downswing
***********************************************************************************************************************	
gen npv_nonsalient_u=.
gen npv_salient_u=.
gen npv_nonsalient_d=.
gen npv_salient_d=.

gen gas_high_up = (ym(2012,2)==mofd(date)|ym(2012,4)==mofd(date))
gen diesel_high_up = (ym(2012,2)==mofd(date)|ym(2012,8)==mofd(date)) 
gen gas_high = -(gas_high_up ) * (x3 == "g") * npv_c 
gen diesel_high = -(diesel_high_up) * (x3 == "d") * npv_c  

gen gas_high_down = (ym(2012,6)==mofd(date)|ym(2012,11)==mofd(date))
gen diesel_high_down = (ym(2012,7)==mofd(date)|ym(2013,4)==mofd(date))
gen gas_low = -(gas_high_down ) * (x3 == "g") * npv_c
gen diesel_low = -(diesel_high_down) * (x3 == "d") * npv_c 

replace npv_nonsalient_u = npv_c + gas_high + diesel_high
replace npv_salient_u = -gas_high-diesel_high

replace npv_nonsalient_d = npv_c + gas_low + diesel_low
replace npv_salient_d = -gas_low-diesel_low

xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient_u npv_salient_u npv_t) ln(4) robust difficult technique(nr 10 bfgs 10 dfp 10)
	estimates store t5_col3u_inc
	mixlbeta p npv_nonsalient_u npv_salient_u npv_t if e(sample), saving("indiv_coefs_t6_col3u_inc.dta") replace

xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient_d npv_salient_d npv_t) ln(4) robust difficult technique(nr 10 bfgs 10 dfp 10)
	estimates store t5_col3d_inc
	mixlbeta p npv_nonsalient_d npv_salient_d npv_t if e(sample), saving("indiv_coefs_t6_col3d_inc.dta") replace

xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient_u npv_nonsalient_d npv_salient_u npv_salient_d npv_t) ln(6) robust difficult technique(nr 10 bfgs 10 dfp 10)
	estimates store t5_col3_inc
	mixlbeta p npv_nonsalient_u npv_salient_u npv_nonsalient_d npv_salient_d npv_t if e(sample), saving("indiv_coefs_t6_col3_inc.dta") replace

***********************************************************************************************************************
*T5 - Col 4 * 75th Percentile
***********************************************************************************************************************
qui summ x21, det
gen gas_25th = (x21<= r(p25)) 
gen gas_50th = (x21>r(p25) & x21<= r(p50))
gen gas_75th =  (x21>r(p50) & x21<= r(p75))
gen gas_100th = (x21>r(p75))

qui summ x22, det
gen diesel_25th = (x22<= r(p25)) 
gen diesel_50th = (x22>r(p25) & x22<= r(p50))
gen diesel_75th =  (x22>r(p50) & x22<= r(p75))
gen diesel_100th = (x22>r(p75))

gen fuel_25th = -(gas_25th*(x3 == "bensin") + diesel_25th*(x3 == "diesel"))*npv_c
gen fuel_50th = -(gas_50th*(x3 == "bensin") + diesel_50th*(x3 == "diesel"))*npv_c
gen fuel_75th = -(gas_75th*(x3 == "bensin") + diesel_75th*(x3 == "diesel"))*npv_c
gen fuel_100th =  -(gas_100th*(x3 == "bensin") + diesel_100th*(x3 == "diesel"))*npv_c

replace npv_nonsalient = - fuel_25th - fuel_50th- fuel_75th
replace npv_salient =   - fuel_100th

xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(nr 10 bfgs 10 dfp 10)
	estimates store t5_col4_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t6_col4_inc.dta") replace










***********************************************************************************************************************
** Salience Indices: news and search
***********************************************************************************************************************

	qui summ x23, det
	gen oilnews_above_mean = (x23>r(mean))
	qui summ x24, det
	gen gasnews_above_mean = (x24>r(mean))
	qui summ x25, det
	gen diesnews_above_mean = (x25>r(mean))

	gen gasdiesnews_above_mean = (x24>r(mean))+(x25>r(mean))
	replace gasdiesnews_above_mean = (gasdiesnews_above_mean>0)

	qui summ x26, det
	gen oilsear_above_mean = (x26>r(mean))
	qui summ x27, det
	gen gassear_above_mean = (x27>r(mean))
	qui summ x28, det
	gen diessear_above_mean = (x28>r(mean))

	gen gasdiessear_above_mean = (x27>r(mean))+(x28>r(mean))
	replace gasdiessear_above_mean = (gasdiessear_above_mean>0)

***********************************************************************************************************************
*Table 6 -- Effect of News Activity
***********************************************************************************************************************

********************************************************************************
*T6 - Col 1 ** Gasoline News
********************************************************************************
	replace npv_salient = gasnews_above_mean*npv_c
	replace npv_nonsalient = npv_c - npv_salient

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t6_col1_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t7_col1_inc.dta") replace

********************************************************************************
*T6 - Col 2 ** Diesel News
********************************************************************************	
	replace npv_salient = diesnews_above_mean*npv_c
	replace npv_nonsalient = npv_c - npv_salient

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t6_col2_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t7_col2_inc.dta") replace
	
********************************************************************************
*T6 - Col 3 **Oil News
********************************************************************************
	replace npv_salient = oilnews_above_mean*npv_c
	replace npv_nonsalient = npv_c - npv_salient

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t6_col4_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t7_col3_inc.dta") replace

	
	
	

********************************************************************************
*Table 7 -- Effect of Search Activity
********************************************************************************

********************************************************************************	
*T7 - Col 1 ** Gasoline Search
********************************************************************************	
	replace npv_salient = gassear_above_mean*npv_c
	replace npv_nonsalient= npv_c - npv_salient

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t7_col1_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t8_col1_inc.dta") replace

********************************************************************************
*T7 - Col 2	** Diesel Search
********************************************************************************
	replace npv_salient = diessear_above_mean*npv_c
	replace npv_nonsalient =  npv_c - npv_salient

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t7_col2_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t8_col2_inc.dta") replace

********************************************************************************
*T7 - Col 3 ** Oil Search
********************************************************************************
	replace npv_salient =  oilsear_above_mean*npv_c
	replace npv_nonsalient =  npv_c - npv_salient

	xi: mixlogit y i.x2 i.x3 i.x4 i.x5 i.x6 i.x7 x8-x16 x29, group(x1)  rand(p npv_nonsalient npv_salient npv_t) ln(4) robust difficult technique(bfgs 50 dfp 50)
	estimates store t7_col4_inc
	mixlbeta p npv_nonsalient npv_salient npv_t if e(sample), saving("indiv_coefs_t8_col3_inc.dta") replace

